import puppeteer from 'puppeteer'
async function main () {
  const browser = await puppeteer.launch({
    headless: false,
    executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
    defaultViewport:
    {
      width: 1920,
      height: 1080,
    }
  });
  const page = await browser.newPage();

  console.log(browser)
  await page.goto('https://www.baidu.com/');
   // 设置视窗大小为 1920x1080
   await page.setViewport({ width: 1920, height: 1080 });

  // Set screen size
  // await page.setViewport({
  //   width: 1920,
  //   height: 1080,
  // });

  // Type into search box
  await page.type('#kw.s_ipt', '吴彦祖');

  // Wait and click on first result
  const searchResultSelector = '#normalSugSearchUl';
  await page.waitForSelector(searchResultSelector);
  await page.click(searchResultSelector);

  // // Locate the full title with a unique string
  // const textSelector = await page.waitForSelector(
  //   'text/Customize and automate'
  // );
  // const fullTitle = await textSelector?.evaluate(el => el.textContent);

  // // Print the full title
  // console.log('The title of this blog post is "%s".', fullTitle);

  // await browser.close();
}
main()